package com.xique.door.biz.service.impl;

import com.xique.common.core.utils.OrikaUtil;
import com.xique.door.bean.dao.CompanyUserCountDAO;
import com.xique.door.bean.domain.Company;
import com.xique.door.bean.dto.CompanyDTO;
import com.xique.door.bean.dto.CompanyUserCountDTO;
import com.xique.door.bean.request.company.CompanyRequest;
import com.xique.door.bean.request.company.UserCompanyRequest;
import com.xique.door.biz.service.ICompanyBizService;
import com.xique.door.service.ICompanyService;
import com.xique.door.service.IUserCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shd
 * @create 2021/12/21 14:16
 */
@Service
public class CompanyBizServiceImpl implements ICompanyBizService {

    @Autowired
    private ICompanyService companyService;

    @Autowired
    private IUserCompanyService userCompanyService;

    @Override
    public List<CompanyDTO> getCompanyList(CompanyRequest request) {

        Company search = new Company();
        search.setParkId(request.getParkId());
        search.setName(request.getName());
        List<Company> list = companyService.selectCompanyList(search);

        return OrikaUtil.converts(list, CompanyDTO.class);
    }

    @Override
    public List<CompanyUserCountDTO> getCompanyUserCountByCompany(UserCompanyRequest request) {
        List<CompanyUserCountDAO> daos = userCompanyService.selectCompanyUserCountByCompanyIds(request.getCompanyIds());

        return OrikaUtil.converts(daos, CompanyUserCountDTO.class);
    }
}
